const mongoose = require('mongoose')
const Content = require('../../model/content')
const Reply = require('../../model/reply')

module.exports = async (req, res) => {
    const { id, flag } = req.params
    var author
    if (flag == 1) {
        try {
            var data = await Content.updateOne({ _id: id }, { status: true })
        } catch (err) {
            console.log(err);
            return res.send({
                data: null,
                meta: {
                    status: 403,
                    msg: '修改失败'
                }
            })
        }

    } else {
        try {
            var data = await Reply.updateOne({ _id: id }, { status: true })

        } catch {
            return res.send({
                data: null,
                meta: {
                    status: 403,
                    msg: '修改失败'
                }
            })
        }
    }

    res.send({
        data: null,
        meta: {
            status: 203,
            msg: '修改成功'
        }
    })
}